<template>
  <j-modal
    :title="title"
    :fullscreen="true"
    :width="1600"
    :visible="visible"
    :maskClosable="false"
    @close="close"
    destroyOnClose
  >
    <a-row :gutter="24">
      <a-col :span="12">
        <h3 style="margin-bottom:29px">{{ title1 }}</h3>
        <TbaleCom :list="list1" :columns="columns1" :param="queryParam" @SelectRow="handleSelectRow" />
      </a-col>
      <a-col :span="12">
        <a-row :gutter="12" style="margin-bottom:20px">
          <a-col :span="8">
            <h3>{{ title2 }}</h3>
          </a-col>
          <a-col :span="8">
            <a-input v-model="queryParamSub.extraName" placeholder="请输入"></a-input>
          </a-col>
          <a-col :span="8">
            <a-button type="primary" icon="search" class="yellow_search_btn" @click="onSearch">查询</a-button>
            <a-button icon="reload" class="clear_btn" @click="searchReset">清除条件</a-button>
          </a-col>
        </a-row>
        <TbaleCom :list="list2" :columns="columns2" :param="queryParamSub" :reload="reload2" />
      </a-col>
    </a-row>
  </j-modal>
</template>

<script>
import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { columns1, columns2, columns3, columns4 } from './checkColumns'
import TbaleCom from '@/views/sj/sjmxgl/gcxmgl/zrcbgl/TbaleCom'
export default {
  name: 'ProjectQualityDetails',
  mixins: [JeecgListMixin],
  components: { TbaleCom },
  data() {
    return {
      queryParam: {
        orgId: '',
        proId: ''
      },
      record: {},
      visible: false,
      title: '详情列表',
      columns1: [],
      columns2: [],
      dataSource1: [],
      dataSource2: [],
      lists: {
        columns1: '/sjmx/queryStartWork',
        columns2: '/sjmx/queryRcDely',
        columns3: '/sjmx/querybudgtDetail',
        columns4: '/sjmx/queryActDetail'
      },
      loading: {
        loading1: false,
        loading2: false
      },
      titles: ['开工信息', '责任下达信息', '预算明细信息', '实际责任成本明细信息'],
      title1: '',
      title2: '',
      list1: '',
      list2: '',
      disableMixinCreated: true,
      queryParamSub: {
        orgId: '',
        proId: '',
        extraName: '',
        name: ''
      },
      reload2: false
    }
  },
  methods: {
    close() {
      this.visible = false
      this.record = {}
      this.queryParam = {}
      this.queryParamSub = {}
    },
    edit(record, orgId) {
      // 有问题
      this.queryParam.proId = record.proId
      this.queryParam.orgId = orgId

      this.queryParamSub.proId = record.proId
      this.queryParamSub.orgId = orgId

      this.record = Object.assign({}, record)
      let { type } = this.record
      switch (type) {
        case '1':
          this.columns1 = columns1(this)
          this.columns2 = columns2(this)
          this.list1 = this.lists.columns1
          this.list2 = this.lists.columns2
          this.title1 = this.titles[0]
          this.title2 = this.titles[1]
          break
        case '2':
        case '3':
          this.columns1 = columns3(this)
          this.columns2 = columns4(this)
          this.list1 = this.lists.columns3
          this.list2 = this.lists.columns4
          this.title1 = this.titles[2]
          this.title2 = this.titles[3]
          break
        default:
          break
      }
      this.visible = true
    },
    handleSelectRow(recoed) {
      // /sjmx/queryActByListName
      this.list2 = '/sjmx/queryActByListName'
      this.queryParamSub.name = recoed.ctlgName
      this.queryParamSub.extraName = ''
      this.reload2 = !this.reload2
    },
    onSearch() {
      this.list2 = '/sjmx/queryActByListName'
      this.reload2 = !this.reload2
    },
    searchReset() {
      switch (this.record.type) {
        case '1':
          this.list2 = this.lists.columns2
          break
        case '2':
        case '3':
          this.list2 = this.lists.columns4
          break
        default:
          break
      }
      this.queryParamSub.name = ''
      this.queryParamSub.extraName = ''
      this.reload2 = !this.reload2
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
</style>
